<template>
  <div class="minaddBxo" v-loading="loading">
      <div class="minaddBxo-footer minaddBxop">
        <p>A资产NFT：{{ obj.a }}</p>
        <p>B资产NFT：{{ obj.b }}</p>
        <p>本次担保交易智能合约地址：{{ obj.contract}}</p>
        <p>A是否已完成转款？</p>
        <div class="flex_div" v-if="obj.aTransfer != null">
            <p><i :class="obj.aTransfer?'ups':''"></i> 是</p>
            <p><i :class="obj.aTransfer?'':'ups'"></i> 否</p>
            <!-- {{scope.row.minted?'是':'否'}} -->
          </div>
        <p>B是否已完成转款？</p>
        <div class="flex_div" v-if="obj.bTransfer != null">
            <p><i :class="obj.bTransfer?'ups':''"></i> 是</p>
            <p><i :class="obj.bTransfer?'':'ups'"></i> 否</p>
            <!-- {{scope.row.minted?'是':'否'}} -->
          </div>
      </div>
  </div>
</template>

<script>
import { GetContractResult } from '../../../api/userMG'
export default {
    props: ['name','swapId'],
    data() {
        return {
            loading:false,
            swapId: this.swapId,
            isTrue:false,
            obj:{
                a:"",
                aTransfer: null,
                b: "",
                bTransfer: null,
                contract: "",
                finish: false
            }
        }
    },

    mounted(){
        window.isTrue = false
        this.onInit()
    },

    beforeDestroy(){
        this.isTrue = true
        // alert(window.isTrue)
    },

    methods: {
        onInit() {
            // alert(this.isTrue)
            if(this.isTrue == true){
                return
            }
            // this.loading = true
            GetContractResult({swapId:this.swapId}).then(res => {
            if (res && res.code != 0) {
                this.$message({
                          type: 'info',
                          message: res.message
                      })
            } else {
                this.loading = false;
                this.obj = res.data
                if(res.data.finish == false){
                    let timer = setTimeout(()=>{
                        clearTimeout(timer)
                        this.onInit()   
                    },3000)
                }
            }
            }).catch(()=>{
                
                let timer = setTimeout(()=>{
                    clearTimeout(timer)
                    this.onInit()   
                },3000)
            })
        },
    },
}
</script>

<style scoped>
  .flex_div{
    display: flex;
  }
  .flex_div p{
    display:flex;
    align-items: center;
    margin: 10px 20px 10px 0!important;
  }
  .flex_div p i{
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #ccc;
    box-sizing: border-box;
    margin-right: 5px;
  }
  .flex_div p i.ups{
    border: 3px solid rgb(10, 190, 52);
  }
  .ipt_div{
      text-align: center;
      border: 1px solid #DCDFE6;
      border-radius: 4px;
      height: 40px;
  }
  .minaddBxo{
      width: 900px;
      margin: 0 auto;
  }
  .minaddBxo .el-select{
      width: 100%;
  }
  .minaddBxo /deep/ .el-form-item__label{
      padding: 0 !important;
  }

  .minaddBxo /deep/ .el-input__inner{
      line-height: 40px;
      height: 40px;
      text-align: center;
  }
  .minaddBxo-footer button{
      background:#1C1E22;
      color: #fff;
      border-radius: 30px;
      width: 300px;
      border:0;
      line-height: 46px;
      font-size: 16px;
      margin: 50px auto 100px;
      display: block;
      cursor: pointer;
  }
  .minaddBxop p{
    margin-top: 36px;
    margin-bottom: 0;
    font-size: 14px;
  }
</style>